package taskscheduler.components;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public abstract class Order {

	private int id;
	private String name;
	private List<Item> orderList = new ArrayList<Item>();
	private Date orderTime;
	
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public List<Item> getOrderList() {
		return orderList;
	}

	public void setOrderList(List<Item> orderList) {
		this.orderList = orderList;
	}

	public Date getOrderTime() {
		return orderTime;
	}
	
	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}
	
	public void addItem(Item item) {
		addItem(item, 1);
	}
	
	public void addItem(Item item, int times) {
		item.setOrder(this);
		item.setQuantity(times);
		orderList.add(item);
	}
	
	public double getTotal(){
		double total = 0;
		
		for (Iterator iterator = orderList.iterator(); iterator.hasNext();) {
			Item item = (Item) iterator.next();
			total += (item.getPrice() * item.getQuantity());
		}
		
		return total;
	}

	
	
}
